package com.xr.hr.sys;

import java.util.Random;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class OrgIns {
	public String getPassword(int n, Random r) {
		String psw = "";
		String str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";
		int pos = 0;
		for (int i = 0; i < n; i++) {
			pos = r.nextInt(62);
			psw += str.charAt(pos);
		}

		return psw;
	}
	
	public boolean checkAlpha(String input) {
		boolean flg = true;
		if (input != null && input.length() > 0) {
			String mask = "^[a-zA-Z]*$";
			Pattern regex = Pattern.compile(mask);
			Matcher matcher = regex.matcher(input);
			flg = matcher.matches();
		}
		return flg;
	}
	
	
	public boolean checkNum(String input) {
		boolean flg = true;
		if (input != null && input.length() > 0) {
			String mask = "^[0-9]*$";
			Pattern regex = Pattern.compile(mask);
			Matcher matcher = regex.matcher(input);
			flg = matcher.matches();
		}
		return flg;
	}
}
